﻿CREATE TABLE [CA].[DefekturaCategoriesVsDepartments] (
    [Id]                  INT           NOT NULL,
    [DefekturaCategoryId] INT           NOT NULL,
    [DepartmentId]        INT           CONSTRAINT [DF__Defectura__Depar__5D01B3B4] DEFAULT ((1)) NOT NULL,
    [SeekDuration]        INT           CONSTRAINT [DF__Defectura__SeekD__5DF5D7ED] DEFAULT ((1)) NOT NULL,
    [Note]                VARCHAR (250) NULL,
    [MD]                  DATETIME      CONSTRAINT [DF__DefecturaCat__MD__5EE9FC26] DEFAULT (getdate()) NOT NULL,
    [MW]                  VARCHAR (50)  CONSTRAINT [DF__DefecturaCat__MW__5FDE205F] DEFAULT (suser_sname()) NOT NULL,
    [ToDelete]            BIT           CONSTRAINT [DF_DefekturaCategoriesVsDepartments_ToDelete] DEFAULT ((0)) NOT NULL,
    CONSTRAINT [PK_DefecturaCategoriesVsDepartments] PRIMARY KEY CLUSTERED ([Id] ASC),
    CONSTRAINT [FK_DefekturaCategoriesVsDepartments_DefekturaCategories] FOREIGN KEY ([DefekturaCategoryId]) REFERENCES [CO].[DefekturaCategories] ([Id]) NOT FOR REPLICATION
);


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Время поиска (дн. - для расчета дефектуры)', @level0type = N'SCHEMA', @level0name = N'CA', @level1type = N'TABLE', @level1name = N'DefekturaCategoriesVsDepartments', @level2type = N'COLUMN', @level2name = N'SeekDuration';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Признак того, что запись нужно удалить из БД всех подразделений', @level0type = N'SCHEMA', @level0name = N'CA', @level1type = N'TABLE', @level1name = N'DefekturaCategoriesVsDepartments', @level2type = N'COLUMN', @level2name = N'ToDelete';

